package imooc_math.sort;

import java.util.Arrays;

import imooc_math.MaxHeap;
import resource.SortTestHelper;

public class HeapSort1 {
	public static void sort(Comparable[] arr){
		MaxHeap mh=new MaxHeap(arr.length);
		for(int i=0;i<arr.length;i++){
			mh.insert(arr[i]);
		}
		for(int i=arr.length-1;i>=0;i--){
			arr[i]=mh.extractMax();
		}
	}
	public static void main(String[] args) {
		
		int N = 10000;
        Integer[] arr = SortTestHelper.generateRandomArray(N, 0, 10000);
        //HeapSort.sort(arr);
        
        SortTestHelper.testSort("imooc_math.HeapSort", arr);
        System.out.println(Arrays.toString(arr));
	}
}
